home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / windows / doc / ui / layout / example / customwindow.000 < prev    next >
Encoding:
Text File  |  1996-02-26  |  2.1 KB  |  84 lines

  1. <!--NewPage-->
  2. <html>
  3. <head>
  4. <title>CustomWindow.java</title>
  5. </head>
  6. <body>
  7. <p>
  8. <hr size=4>
  9.  
  10. <h2>
  11.     CustomWindow.java
  12. </h2>
  13. <p>
  14. <blockquote>
  15.  
  16. <pre>
  17.  
  18. /*
  19.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  20.  *
  21.  * Permission to use, copy, modify, and distribute this software
  22.  * and its documentation for NON-COMMERCIAL purposes and without
  23.  * fee is hereby granted provided that this copyright notice
  24.  * appears in all copies. Please refer to the file "copyright.html"
  25.  * for further important copyright and licensing information.
  26.  *
  27.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  28.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  29.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  30.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  31.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  32.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  33.  */
  34. import java.awt.*;
  35.  
  36. public class CustomWindow extends Frame {
  37.     private boolean inAnApplet = true;
  38.      
  39.     public CustomWindow() {
  40.     setLayout(new DiagonalLayout());
  41.         setFont(new Font("Helvetica", Font.PLAIN, 14));
  42.    
  43.     add(new Button("Button 1"));
  44.     add(new Button("Button 2"));
  45.     add(new Button("Button 3"));
  46.     add(new Button("Button 4"));
  47.     add(new Button("Button 5"));
  48.  
  49.         //resize(199, 145);
  50.     }
  51.  
  52.     public synchronized boolean handleEvent(Event e) {
  53.         if (e.id == Event.WINDOW_ICONIFY) {//DOESN'T seem to be necessary
  54.             hide(); 
  55.             return true;
  56.         }
  57.         if (e.id == Event.WINDOW_DESTROY) {
  58.             if (inAnApplet) {
  59.                 dispose();
  60.                 return true;
  61.             } else {
  62.                 System.exit(0);
  63.             }
  64.         }   
  65.         return super.handleEvent(e);
  66.     }
  67.  
  68.     public static void main(String args[]) {
  69.     CustomWindow window = new CustomWindow();
  70.         window.inAnApplet = false;
  71.  
  72.     window.setTitle("CustomWindow Application");
  73.     window.pack();
  74.     window.show();
  75.     }
  76. }
  77. </pre>
  78. </blockquote>
  79. <p>
  80. <hr size=4>
  81. <p>
  82. </body>
  83. </html>
  84.